observeDOM.constructor   A
last analyzed

Complexity

Conditions 1
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 2
nop 0
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A domchanged.js ➔ observeDOM 0 16 3
A domchanged.js ➔ ... ➔ ??? 0 5 3
1
var observeDOM = (function(){
2
    var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
3
        eventListenerSupported = window.addEventListener;
4
5
    return function(obj, callback){
6
        if( MutationObserver ){
7
            // define a new observer
8
            var obs = new MutationObserver(function(mutations, observer){
0 ignored issues
show
Unused Code introduced by
The parameter observer is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
9
                if( mutations[0].addedNodes.length || mutations[0].removedNodes.length ){
10
                    callback();
11
                }
12
            });
13
            // have the observer observe foo for changes in children
14
            obs.observe( obj, { childList:true, subtree:true });
15
        }
16
        else if( eventListenerSupported ){
17
            obj.addEventListener('DOMNodeInserted', callback, false);
18
            obj.addEventListener('DOMNodeRemoved', callback, false);
19
        }
20
    };
21
})();
22